// IDEA: Couting number according the last character of word. And print new line after the last character.
// Using state IN and OUT.

#include <stdio.h>

#define OUT 0
#define IN 1

int main()
{
    int c;
    int nw;
    int state;

    state = OUT;
    nw = 0;

    printf("=== Word number couting & print one word one line. === \n");
    printf("1.Press ctrl+D to end printing. \n2.Dismiss symbols.\n\n");

    while ((c = getchar()) != EOF)
    {
        if (c != ' ' && c != '\t' && c != '\n')
            state = IN,
            putchar(c);
        else if (state = IN)
            state = OUT,
            putchar('\n'),
            nw++;
    }

    printf("Word number is ( %d ).\n", nw);
    return 0;
}